package com.itsoku.util;

import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.RandomUtils;

/**
 * @Description
 * @Author fengleifl-hzgs
 * @Date 2025/9/28
 * @since
 */
@Slf4j
public class SmsUtil {

    /**
     * 发送短信
     */
    public static boolean sendSms() {

        // 使用随机数模拟重试场景
        //String num = "" + RandomUtils.nextInt(0, 4);
        String num = "" + 0;
        log.info("[SmsUtil][sendSms]>>>> random num = {}", num);

       return switch (num) {
            case "0" ->
                // 模拟发生参数异常
                    throw new IllegalArgumentException("参数有误！");
            case "1" ->
                // 模拟发生数组越界异常
                    throw new ArrayIndexOutOfBoundsException("数组越界！");
            case "2" ->
            // 模拟成功
                true;
            case "3" ->
                // 模拟发生空指针界异常
                    throw new NullPointerException();
            default ->
                // 未成功则返回false
                    false;
        };

    }
}
